using System;
using System.IO;
using System.Globalization;
using System.Net;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Xml;

namespace Website
{
    public sealed class UnsupportedMediaTypeActionResult : ActionResult
    {
        private const string HtmlTemplate = "<html>" +
            "<head><title>Sorry, the media type you provided is not supported</title></head>" +
            "<body>" +
            "<h1>Sorry, the media type you provided is not supported</h1>" +
            "</body>" +
            "</html>";

        public override void ExecuteResult(ControllerContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException("context");
            }

            HttpResponseBase response = context.HttpContext.Response;

            response.StatusCode = (int)HttpStatusCode.UnsupportedMediaType;
            response.ContentType = "text/html";
            response.Cache.SetCacheability(HttpCacheability.NoCache);

            response.Write(HtmlTemplate);
        }
    }
}